package com.banciyuan.bcywebview.biz.webdetail;

import com.banciyuan.bcywebview.base.factory.TimelineFactory;
import com.banciyuan.bcywebview.biz.detail.complex.ComplexDetailActivity;

import de.greenrobot.daoexample.model.DetailType;

/**
 * Created by hfxt2008
 * <p/>
 * 这个detail和DetailActivity代码基本一样，少了分享部分，这个是为了让网络连接点进app专门用来监听intent的
 * 注意所有DetailActivity的改动都要同步进来。
 * <p/>
 * PS：可以对这个模式进行简化，比如把intent的过滤放到mainactivity里什么的，不改动也可以。
 */
public class DetailActivity4WebSite extends ComplexDetailActivity {

    private String from_path;

    @Override
    protected void initArgs() {
        super.initArgs();
        try {
            from_path = getIntent().getData().getPath();
            setWebParmas();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    private void setWebParmas() {
        mDetailType = new DetailType();
        String[] paths = from_path.split("/");
        try {
            if (paths[1].equals("daily")) {
                mDetailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_DAILY);
                mDetailType.setUd_id(paths[paths.length - 1]);
            }
            if (paths[1].equals("coser")) {
                mDetailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_COSER);
                mDetailType.setRp_id(paths[paths.length - 1]);
                mDetailType.setCp_id(paths[paths.length - 2]);
            }
            if (paths[1].equals("illust")) {
                mDetailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_ILLUST);
                mDetailType.setRp_id(paths[paths.length - 1]);
                mDetailType.setDp_id(paths[paths.length - 2]);
            }
            if (paths[1].equals("group")) {
                mDetailType.setTimelineType(TimelineFactory.TIMELINE_TYPE_GROUP);
                mDetailType.setPost_id(paths[paths.length - 1]);
                mDetailType.setGid(paths[paths.length - 2]);
            }
            complexHelper.setmDetailType(mDetailType);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}